<div *ngIf="trip" class="form-horizontal">
    <form #tripform="ngForm" novalidate>
    <div class="row">
        <div class="form-group col-sm-6">
            <label class="form-control-label">ID:</label>
            <input name="trip_id" [(ngModel)]="trip.trip_id" placeholder="车次ID" class="form-control" readonly/>
        </div>
        <div class="form-group col-sm-6">
            <label class="form-control-label">车次名称:</label>
            <input name="trip_name" #trip_name="ngModel" [(ngModel)]="trip.trip_name" placeholder="车次名称" class="form-control" required />
            <span style="color:red" [hidden]="trip_name.valid || trip_name.pristine">
                名称不能为空。
            </span>
        </div>
    </div>
    <div class="row">
        <div class="form-group col-sm-6">
            <label class="form-control-label">发车时间:</label>
            <input name="trip_time" #trip_time="ngModel" [(ngModel)]="trip.trip_time" placeholder="发车时间" class="form-control"
             required pattern="^((1|0?)[0-9]|2[0-3]):([0-5][0-9])" />
            <span style="color:red" [hidden]="trip_time.valid || trip_time.pristine">
                时间格式不正确。
            </span>
        </div>
        <div class="form-group col-sm-6">
            <label class="form-control-label">票价:</label>
            <input name="price" #price="ngModel" [(ngModel)]="trip.price" placeholder="票价" class="form-control" type="number" 
            required  pattern="^[1-9]\d*(\.\d+)?$"/>
            <span style="color:red" [hidden]="price.valid || price.pristine">
                输入有误。
            </span>
        </div>
    </div>
    <div class="row">
        <div class="form-group col-sm-6">
            <label for="carrier_id" class="form-control-label">所属公司:</label>
            <select name="carrier_id" class="form-control"  required [(ngModel)]="trip.carrier_id">
                <option *ngFor="let carrier of carriers" [value]="carrier.carrier_id">{{carrier.carrier_name}}</option>
            </select>
        </div>
        <div class="form-group col-sm-6">
            <label for="bus_id" class="form-control-label">车辆:</label>
            <select class="form-control" id="power" required [(ngModel)]="trip.bus_id" name="bus_id">
                <option *ngFor="let bus of buses" [value]="bus.bus_id">{{bus.plate_number}}</option>
            </select>
        </div>
    </div>
    <div class="row">
        <div class="form-group col-sm-6">
            <label for="driver_id" class="form-control-label">司机:</label>
            <select class="form-control" id="power" required [(ngModel)]="trip.driver_id" name="driver_id">
                <option *ngFor="let driver of drivers" [value]="driver.driver_id">{{driver.driver_name}}</option>
            </select>
        </div>
        <div class="form-group col-sm-6">
            <label class="form-control-label">是否有效:</label>
            <select class="form-control" id="status" [(ngModel)]="trip.status" name="status">
            <option>YES</option>
            <option>NO</option>
        </select>
        </div>
    </div>
    <div class="row">
        <div class="form-group">
            <div class="col-sm-1">
                <!--<button class="btn btn-danger" *ngIf="trip.trip_id" (click)="delete()">删除</button>-->
            </div>
            <div class="offset-sm-9 col-sm-1">
                <button class="btn btn-default" (click)="cancel()">取消</button>
            </div>
            <div class="col-sm-1">
                <button [disabled]="!tripform.form.valid" class="btn btn-primary" (click)="save()">保存</button>
            </div>
        </div>
    </div>
    </form>
</div>
